home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Snippets / Equation Evaluator / CEquation ƒ / main.cp < prev   
Encoding:
Text File  |  1995-11-06  |  754 b   |  32 lines  |  [TEXT/MPCC]

  1. #include <stdlib.h>
  2. #include <unix.h>
  3. #include "CEquation.h"
  4.  
  5. main( short argc, char* argv[] )
  6. {
  7.     TYPE  result;
  8.     short   ec;
  9.     short   a;
  10.     char  line[1024];
  11.  
  12.     CEquation *theEquation = new CEquation;
  13.     theEquation->ClearAllVars();
  14.     printf( "\nEE - Equation Evaluator" );
  15.     printf( "\nBy Mark Morley  December 1991" );
  16.     printf( "\nEnter EXIT to quit.\n" );
  17.     printf( "\nEE> " );
  18.  
  19.     for( gets( line ); !feof( stdin ); gets( line ) )
  20.     {
  21.       /* Call the evaluator. */
  22.      if( (ec = theEquation->Evaluate( line, &result, &a )) == E_OK )
  23.      {
  24.         /* Only display the result if it was not an assignment. */
  25.         if( ! a )
  26.            printf( "%g\n", result );
  27.      }
  28.      else if( ec != E_EMPTY ) theEquation->ReportError();
  29.       printf( "EE> " );
  30.    }
  31. }
  32.